<?php
/**
 * Minhlog Domain_Mapper 友情链接类型类
 *
 * LICENSE
 *
 * This source file is subject to the new BSD license that is bundled
 * with this package in the file LICENSE.txt.
 *
 * @category   Domain
 * @package    Domain_DataMapper
 * @copyright  Copyright (c) 2009-2010 Minh.Shu@gmail.com
 * @license    New BSD License
 * @author     Minh.Shu
 * @version    $Id: Type.php 2 2010-01-17 13:49:08Z Minh.Shu $
 *
 */

class Domain_DataMapper_Link_Type extends Domain_DataMapper_Abstract
{
    protected $_tableClassName = 'Domain_Table_Link_Type';

    protected $_dataMapper = array (
            'typeId'       => 'type_id',
            'typeName'     => 'type_name',
            'typeDesc'     => 'type_desc',
            'displayOrder' => 'display_order'
    );

    /**
     * 查询全部友情链接类型
     * @param boolean $order
     * @return object|void
     */
    public function findAllType($order = true)
    {
        return $this->getTable()->fetchAll($this->findAllTypeStatement($order));
    }

    /**
     * 封装查询全部友情链接类型SQL对象
     * @param boolean $order
     * @return Zend_Db_Table_Select
     */
    private function findAllTypeStatement($order)
    {
        $select = $this->getTable()->select();
        if(false === $order) {
            $select->order('type_id DESC');
        }else{
            $select->order('display_order')
                    ->order('type_id DESC');
        }
        return $select;
    }
}